package net.hn.hnms.biz.plan.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.plan.request.ExecutionTunnelRepairReq;
import net.hn.hnms.biz.plan.service.IExecutionTunnelRepairService;
import net.hn.hnms.biz.plan.vo.ExecutionTunnelRepairVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "巷道工作模块", tags = {"巷道工作执行"})
@RestController
@RequestMapping("/execution/tunnelRepair")
public class ExecutionTunnelRepairController extends BaseController {

    @Resource
    private IExecutionTunnelRepairService executionTunnelRepairService;

    /**
     * 新增巷道修复执行
     */
    @ApiOperation("新增巷道修复执行")
    @SaCheckPermission("execution:tunnelRepair:add")
    @PostMapping("/add")
    @Log(title = "新增巷道修复执行", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody ExecutionTunnelRepairReq executionTunnelRepair) {
        return toAjax(executionTunnelRepairService.insert(executionTunnelRepair));
    }

    /**
     * 删除巷道修复执行
     */
    @ApiOperation("删除巷道修复执行")
    @SaCheckPermission("execution:tunnelRepair:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除巷道修复执行", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        executionTunnelRepairService.deleteBatch(idList);
        return R.ok();
    }

    /**
     * 修改巷道修复执行
     */
    @ApiOperation("修改巷道修复执行")
    @SaCheckPermission("execution:tunnelRepair:update")
    @PutMapping("/update")
    @Log(title = "修改巷道修复执行", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody ExecutionTunnelRepairReq executionTunnelRepair) {
        executionTunnelRepairService.updateById(executionTunnelRepair);
        return R.ok();
    }

    /**
     * 获取巷道修复执行分页列表
     */
    @ApiOperation("获取巷道修复执行分页列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<ExecutionTunnelRepairVo>> page(ExecutionTunnelRepairReq executionTunnelRepair, PageQuery pageQuery) {
        return R.ok(executionTunnelRepairService.selectPageList(executionTunnelRepair, pageQuery));
    }

    /**
     * 获取巷道修复执行详情
     */
    @ApiOperation("获取巷道修复执行详情")
    @GetMapping("/{id}")
    public R<ExecutionTunnelRepairVo> detail(@PathVariable("id") String id) {
        return R.ok(executionTunnelRepairService.selectDetailById(id));
    }

}
